<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    @include('public.h5_head')
    <title>积分等级</title>
    <script src="{{ env('CDN_DOMAIN_NAME') }}/js/commonjs/rem.js"></script>
    <link rel="stylesheet" type="text/css" href="{{ env('CDN_DOMAIN_NAME') }}/css/commoncss/common.css"/>
    <link rel="stylesheet" type="text/css" href="{{ env('CDN_DOMAIN_NAME') }}/css/member.css"/>
</head>
<script src="{{ env('CDN_DOMAIN_NAME') }}/js/commonjs/iscroll.js"></script>
<script src="{{ env('CDN_DOMAIN_NAME') }}/js/app.js"></script>
<script src="{{ env('CDN_DOMAIN_NAME') }}/js/commonjs/common.js"></script>
<body>
<div id="box_member">
    <div class="wrap">
        <div class="member">
            <div class="member_top">
                <img class="member_blur" src="/img/bg-p.jpg"/>
                <div class="member_name">
                    <div class="member_level">
                        <div class="mylevel">我的等级:</div>
                        <div class="bglevel">Lv<span class="now_level">0</span></div>
                    </div>
                    <div class="member_num"><span class="member_now">{{ Auth::user()->integral }}</span>/<span class="member_next">100000</span></div>
                    <div class="member_graticule">
                        <div class="member_bar1"><p class="bar1"></p></div>
                        <div class="change_level">Lv<span class="next_level">0</span></div>
                    </div>
                    <div class="consumer">当年消费:</div>
                    <div class="member_number"><span class="now_sum">{{ Auth::user()->integral }}</span>/<span class="next_sum">100000</span></div>
                    <div class="graticule">
                        <div class="member_bar2"><p class="bar2"></p></div>
                    </div>
                    <p class="rule" onclick="window.location.href='/user/regulation'">积分规则<span class="bg_rule"></span></p>
                </div>
            </div>
            <div class="member_bottom">
                <p class="member_notice">等级与权益</p>
                <p class="member_content">大品优选制定用户等级制，旨在为用户提供折扣权益。同时，用户历史消费行为将作为折扣制和信用制的重要依据被系统记录，为提供差异化、个性化的定制服务，提供大数据支撑。</p>
            </div>
            <div class="member_center">
                <table class="tab" border="1" cellspacing="0" cellpadding="0" bgcolor="">
                    <tr><th colspan="3" rowspan="1">历史等级规则表</th></tr>
                    <tr><td>等级</td><td>历史积分</td><td>等级备注</td></tr>
                    <tr><td>Lv0</td><td>[0w,10w)</td><td>起步</td></tr>
                    <tr><td>Lv1</td><td>[10w,20w)</td><td>-</td></tr>
                    <tr><td>Lv2</td><td>[20w,40w)</td><td>-</td></tr>
                    <tr><td>Lv3</td><td>[40w,80w)</td><td>-</td></tr>
                    <tr><td>Lv4</td><td>[80w,160w)</td><td>-</td></tr>
                    <tr><td>Lv5</td><td>[160w,320w)</td><td>-</td></tr>
                    <tr><td>Lv6</td><td>[320w,640w)</td><td>-</td></tr>
                    <tr><td>Lv7</td><td>[640w,1280w)</td><td>-</td></tr>
                    <tr><td>Lv8</td><td>[1280w,2560w)</td><td>-</td></tr>
                    <tr><td>Lv9</td><td>[2560w,+)</td><td>封顶</td></tr>
                </table>
            </div>
            <div class="member_bottom">
                <p class="member_notice">等级有效期</p>
                <p class="member_content">应用等级仅仅和历史积分有关，历史积分上升到一定的数值区间时，会有对应的等级。由于历史积分是永久有效的，所以等级也是永久有效。</p>
            </div>


        </div>
    </div>
</div>
</body>
<script>
    scroll();
    //等级长条
	var _num1=parseInt($(".member_now").text());
    $('.member_next').text(history_scores(_num1))
	var _num2=parseInt($(".member_next").text());
	var W=parseInt($(".member_bar1").width())
	var w=(_num1/_num2)*W;

	if(w >= W){

		w=0;
		$(".bar1").width(w+"px");
	}
	$(".bar1").width(w+"px");
	//当年消费长条
	var _num3=parseInt($(".now_sum").text());
    $('.next_sum').text(now_score(_num3));
	var _num4=parseInt($(".next_sum").text());
	var _W=parseInt($(".member_bar2").width())
	var _w=(_num3/_num4)*W;
	if(_w>=_W){
		_w=0;
		$(".bar2").width(_w+"px");
	}
	$(".bar2").width(_w+"px");

    $(document).ready(function () {
        var integral = '{{ Auth::user()->integral }}';
        $('.now_level').text(history_score(integral));
        var next_lev = history_score(integral)+1;
        if(next_lev == 10)
        {
            next_lev = 9;
        }
        $('.next_level').text(next_lev);
    });
    function history_score(score) {
        if( score >= 0 && score < 100000)
        {
            return 0;
        }else if (score >= 100000 && score < 200000)
        {
            return 1;
        }else if (score >= 200000 && score < 400000)
        {
            return 2;
        }else if (score >= 400000 && score < 800000)
        {
            return 3;
        }else if (score >= 800000 && score < 1600000)
        {
            return 4;
        }else if (score >= 1600000 && score < 3200000)
        {
            return 5;
        }else if (score >= 3200000 && score < 6400000)
        {
            return 6;
        }else if (score >= 6400000 && score < 12800000)
        {
            return 7;
        }else if (score >= 12800000 && score < 25600000)
        {
            return 8;
        }else if (score >= 25600000 )
        {
            return 9;
        }
        return -1;
    }

    //当年积分
    function now_score(integral){
        if( integral >= 0 && integral < 100000){
            return 100000;
        }else if (integral >= 100000 && integral < 200000){
            return 200000;
        }else if (integral >= 200000 && integral < 300000){
            return 300000;
        }else if (integral >= 300000 && integral < 400000){
            return 400000;
        }else if (integral >= 400000 && integral < 500000){
            return 500000;
        }else if (integral >= 500000 && integral < 600000){
            return 600000;
        }else if (integral >= 600000 && integral < 700000){
            return 700000;
        }else if (integral >= 700000 && integral < 800000){
            return 800000;
        }else if (integral >= 800000 && integral < 900000){
            return 900000;
        }else if (integral >= 900000 && integral < 1000000){
            return 1000000;
        }else if (integral >= 1000000 && integral < 1280000){
            return 1280000;
        }else if (integral >= 1280000 ){
            return "--";
        }
    }

    function history_scores(score) {
        if( score >= 0 && score < 100000)
        {
            return 100000;
        }else if (score >= 100000 && score < 200000)
        {
            return 200000;
        }else if (score >= 200000 && score < 400000)
        {
            return 400000;
        }else if (score >= 400000 && score < 800000)
        {
            return 800000;
        }else if (score >= 800000 && score < 1600000)
        {
            return 1600000;
        }else if (score >= 1600000 && score < 3200000)
        {
            return 3200000;
        }else if (score >= 3200000 && score < 6400000)
        {
            return 6400000;
        }else if (score >= 6400000 && score < 12800000)
        {
            return 12800000;
        }else if (score >= 12800000 && score < 25600000)
        {
            return 25600000;
        }else if (score >= 25600000 )
        {
            return 25600000;
        }
        return '--';
    }
</script>
</html>
